#include<linux/init.h>
#include<linux/module.h>
#include<linux/sched.h>
#include<linux/sem.h>
#include<linux/list.h>

MODULE_LICENSE("Dual BSD/GPL");
static int __init  traverse_init(void)
{
      struct task_struct *pos = NULL;
      struct list_head *current_head = NULL;
      int count = 0;
      
      printk("Traversal module is working..\n");
      
      current_head = &(current->tasks);
      list_for_each_entry(pos, current_head, tasks)
      {
             count++;
             printk("[process %d]: %s\'s pid is %d\n",count, pos->comm, pos->pid);
      }
      printk(KERN_ALERT"The number of process is:%d\n",count);
      return 0;
}

static void __exit traverse_exit(void)
{
  printk("hello world exit\n");
}

module_init(traverse_init);
module_exit(traverse_exit);
